package com.woniu.mealsService.que;

import org.springframework.amqp.core.Queue;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;


/**
 * @author jiang
 */
@Configuration
public class OrderQue {
    @Bean
    // 查询是否在时间内，商家时候手动接单
    public Queue delayOrder(){
        Map<String, Object> args = new HashMap<String, Object>();
        args.put("x-dead-letter-exchange", "delay_Update_take");
        args.put("x-dead-letter-routing-key", "order");
        args.put("x-message-ttl",15*60*1000);
//        args.put("x-message-ttl",60*1000);
        return new Queue("delay_Update_Order", true, false, false, args);
    }
    @Bean
    public Queue updateOrder(){
        return new Queue("query_alipay_status");
    }
    @Bean
    // 向支付宝查询订单支付状态
    public Queue delayAlipay(){
        Map<String, Object> args = new HashMap<String, Object>();
        args.put("x-dead-letter-exchange", "delay_Update_alipayquery");
        args.put("x-dead-letter-routing-key", "alipay");
//        args.put("x-message-ttl",15*60*1000);
        args.put("x-message-ttl",60*1000);
        return new Queue("delay_alipay_status", true, false, false, args);
    }
    @Bean
    // 订单关闭
    public Queue delayCloseOrder(){
        Map<String, Object> args = new HashMap<String, Object>();
        args.put("x-dead-letter-exchange", "delay_Update_alipayclose");
        args.put("x-dead-letter-routing-key", "close");
        // 设置两小时后自动关闭订单
        args.put("x-message-ttl",60*1000);
        return new Queue("delay_order_close", true, false, false, args);
    }
    @Bean
    // 订单退款
    public Queue refundOrder(){
        return new Queue("refund_order");
    }
    @Bean
    // 错误订单信息存储
    public Queue errorOrder(){
        return new Queue("error_order");
    }
}
